<template>
  <div>
    <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="总价格">
                <span>{{ props.row.price }}</span>
              </el-form-item>
              <el-form-item label="联系人电话">
                <span>{{ props.row.orderphone }}</span>
              </el-form-item>
              <el-form-item label="配送人">
                <span>{{ props.row.senduser }}</span>
              </el-form-item>
              <el-form-item label="配送人电话">
                <span>{{ props.row.sendphone }}</span>
              </el-form-item>
              <el-form-item label="收货人">
                <span>{{ props.row.receivename }}</span>
              </el-form-item>
              <el-form-item label="送餐地址">
                <span>{{ props.row.address }}</span>
              </el-form-item>
              <el-form-item label="支付方式">
                <span>{{ props.row.paytype }}</span>
              </el-form-item>
              <el-form-item label="下单时间">
                <span>{{ props.row.orderdate }}</span>
              </el-form-item>
              <el-form-item label="商家接单时间">
                <span>{{ props.row.orderdate }}</span>
              </el-form-item>
              <el-form-item label="取消时间">
                <span>{{ props.row.canceldate }}</span>
              </el-form-item>
              <el-form-item label="配送方式">
                  <span>{{ props.row.dispatching }}</span>
              </el-form-item>
               <el-form-item label="预计送达时间">
                  <span>{{ props.row.reachdate }}</span>
               </el-form-item>
               <el-form-item label="是否评价">
                  <span>{{ props.row.evaluate }}</span>
                </el-form-item>
               <el-form-item label="订单状态">
                  <span>{{ props.row.state }}</span>
               </el-form-item>
              <el-form-item label="订单备注">
                  <span>{{ props.row.remarks }}</span>
               </el-form-item>
              <el-form-item label="撤单">
                <span>
                    <el-row>
                      <el-button type="primary" @click="noAcceptOrder(props.row)">撤单键</el-button>
                    </el-row>
                </span>
              </el-form-item>
              <el-form-item label="接单">
                    <span>
                       <el-row>
                           <el-button type="warning" @click="acceptOrder(props.row)">接单键</el-button>
                       </el-row>
                    </span>
               </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column
          label="订单编号"
          prop="ordernum">
        </el-table-column>
        <el-table-column
          label="商家ID"
          prop="storeId">
        </el-table-column>
        <el-table-column
          label="订餐人"
          prop="orderuser">
        </el-table-column>
      </el-table>
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-size="this.pageSize"
            layout="total, prev, pager, next"
            :total="this.total">
          </el-pagination>
        </div>
  </div>
</template>

<script>
export default {
name: "OrderByStore",
data() {
      return {
        currentPage:1,
        pageSize:10,
        total:1000,
        pageSize:10,
        tableData: [{
          id: '12987122',
          name: '好滋好味鸡蛋仔',
          category: '江浙小吃、小吃零食',
          desc: '荷兰优质淡奶，奶香浓而不腻',
          address: '上海市普陀区真北路',
          shop: '王小虎夫妻店',
          shopId: '10333'
        }, {
          id: '12987123',
          name: '好滋好味鸡蛋仔',
          category: '江浙小吃、小吃零食',
          desc: '荷兰优质淡奶，奶香浓而不腻',
          address: '上海市普陀区真北路',
          shop: '王小虎夫妻店',
          shopId: '10333'
        }, {
          id: '12987125',
          name: '好滋好味鸡蛋仔',
          category: '江浙小吃、小吃零食',
          desc: '荷兰优质淡奶，奶香浓而不腻',
          address: '上海市普陀区真北路',
          shop: '王小虎夫妻店',
          shopId: '10333'
        }, {
          id: '12987126',
          name: '好滋好味鸡蛋仔',
          category: '江浙小吃、小吃零食',
          desc: '荷兰优质淡奶，奶香浓而不腻',
          address: '上海市普陀区真北路',
          shop: '王小虎夫妻店',
          shopId: '10333'
        }]
      }
    },
    methods:{
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
          console.log(`当前页: ${val}`);
          this.currentPage = val;
          this.init_Data()
       },
      acceptOrder(row){
        alert("接单")
        this.$http.post("/dietOrder/acceptOderByStore/",row).then(resp=>{
          if(resp.data.code==200){
            alert("接单成功")
          }
        })
      },
      noAcceptOrder(row){
        alert("不接单")
        this.$http.post("/dietOrder/noAcceptOderByStore/",row).then(resp=>{
            if(resp.data.code==200){
              alert("撤单成功")
             }
        })
      },
      init_Data(){
        this.$http.get("/dietOrder/getOderByStore/"+this.currentPage+"/"+this.pageSize+"/").then(resp=>{
          console.log(resp)
          if(resp.data.code==200){
            console.log(resp)
            this.tableData=resp.data.data.records
            this.total=resp.data.data.total
            this.currentPage=resp.data.data.current
            alert("初始化成功!")
          }else{
            alert("初始化失败!")
          }
        })
      }
    },
    created(){
      this.init_Data()
    }
}
</script>

<style scoped>
.demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }
  .demo-table-expand .el-form-item[data-v-ac985f38] {
      margin-right: 0;
      margin-bottom: 0;
      width: 9%;
  }
</style>
